home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Standard Arrangements / GrowOnRightArrangement.cp < prev    next >
Text File  |  1997-06-28  |  3KB  |  160 lines

  1. // GrowOnRightArrangement.cp
  2.  
  3. #ifndef GrowOnRightArrangement_h
  4. #include "GrowOnRightArrangement.h"
  5. #endif
  6. #ifndef MinMax_h
  7. #include "MinMax.h"
  8. #endif
  9.  
  10. GrowOnRightArrangement::GrowOnRightArrangement( WindowFocus& focus )
  11.   : grow( focus )
  12.   {
  13.     RightLine().SetView( rightLine );
  14.     Grow().SetView( grow );
  15.   }
  16.  
  17. void GrowOnRightArrangement::Arrange( Rectangle bounds )
  18.   {
  19.     Rectangle grow( bounds.right - barSize,
  20.                          bounds.bottom - barSize,
  21.                          bounds.right,
  22.                          bounds.bottom );
  23.  
  24.     Rectangle main( bounds.left,
  25.                          bounds.top,
  26.                          grow.left,
  27.                          bounds.bottom );
  28.     
  29.     Rectangle rightLine( grow.left,
  30.                                 bounds.top,
  31.                                 grow.left + 1,
  32.                                 grow.top );
  33.     
  34.     Rectangle rightBar( rightLine.right,
  35.                               bounds.top,
  36.                               bounds.right,
  37.                               grow.top );
  38.     
  39.     Main().SetBounds( main );
  40.     Right().SetBounds( rightBar );
  41.     RightLine().SetBounds( rightLine );
  42.     Grow().SetBounds( grow );
  43.   }
  44.  
  45. uint16 GrowOnRightArrangement::MinimumHeight() const
  46.   {
  47.     uint16 size = Right().Size().MinimumHeight();
  48.     
  49.     Assert( size <= maxint16 - barSize );
  50.     
  51.     size += barSize;
  52.     
  53.     return Max( size, Main().Size().MinimumHeight() );
  54.   }
  55.  
  56. uint16 GrowOnRightArrangement::MinimumWidth() const
  57.   {
  58.     uint16 size = Main().Size().MinimumWidth();
  59.     
  60.     Assert( size <= maxint16 - barSize );
  61.     
  62.     return size + barSize;
  63.   }
  64.  
  65. uint16 GrowOnRightArrangement::MaximumHeight() const
  66.   {
  67.     uint16 size = Right().Size().MaximumHeight();
  68.     
  69.     if ( size >= maxint16 - barSize )
  70.         size = maxint16;
  71.      else
  72.         size += barSize;
  73.     
  74.     return Max( size, Main().Size().MaximumHeight() );
  75.   }
  76.  
  77. uint16 GrowOnRightArrangement::MaximumWidth() const
  78.   {
  79.     uint16 size = Main().Size().MaximumWidth();
  80.     
  81.     if ( size >= maxint16 - barSize )
  82.         return maxint16;
  83.     
  84.     return size + barSize;
  85.   }
  86.  
  87. uint16 GrowOnRightArrangement::ReasonableHeight() const
  88.   {
  89.     uint16 size = Right().Size().ReasonableHeight();
  90.     
  91.     Assert( size <= maxint16 - barSize );
  92.     
  93.     size += barSize;
  94.     
  95.     return Max( size, Main().Size().ReasonableHeight() );
  96.   }
  97.  
  98. uint16 GrowOnRightArrangement::ReasonableWidth() const
  99.   {
  100.     uint16 size = Main().Size().ReasonableWidth();
  101.     
  102.     Assert( size <= maxint16 - barSize );
  103.     
  104.     return size + barSize;
  105.   }
  106.  
  107. uint16 GrowOnRightArrangement::BestHeight() const
  108.   {
  109.     uint16 size = Main().Size().BestHeight();
  110.     
  111.     Assert( size <= maxint16 - barSize );
  112.     size += barSize;
  113.     
  114.     size = Min( size, Right().Size().MaximumHeight() );
  115.     size = Max( size, Right().Size().MinimumHeight() );
  116.     
  117.     return size - barSize;
  118.   }
  119.  
  120. uint16 GrowOnRightArrangement::BestHeight( uint16 bound ) const
  121.   {
  122.     uint16 size = Main().Size().BestHeight( bound );
  123.  
  124.     Assert( size <= maxint16 - barSize );
  125.     size += barSize;
  126.     
  127.     size = Min( size, Right().Size().MaximumHeight() );
  128.     size = Max( size, Right().Size().MinimumHeight() );
  129.     
  130.     size -= barSize;
  131.     
  132.     size = Min( size, bound );
  133.         
  134.     return size;
  135.   }
  136.  
  137. uint16 GrowOnRightArrangement::BestWidth() const
  138.   {
  139.     uint16 size = Main().Size().BestWidth();
  140.     
  141.     Assert( size <= maxint16 - barSize );
  142.     
  143.     return size + barSize;
  144.   }
  145.  
  146. uint16 GrowOnRightArrangement::BestWidth( uint16 bound ) const
  147.   {
  148.     if ( bound <= barSize )
  149.         return bound;
  150.     
  151.     bound -= barSize;
  152.     
  153.     uint16 size = Main().Size().BestWidth( bound );
  154.     size = Min( size, bound );
  155.     
  156.     Assert( size <= maxint16 - barSize );
  157.     
  158.     return size + barSize;
  159.   }
  160.